<?php
session_start();
function Obtener_Conexion(){
	require("morsa.inc"); 
	$conexion=pg_connect("host=$DB_SERVER dbname=$DB user=$DB_LOGIN password=$DB_PASS") or die ("No pudo conectar con $DB en $DB_SERVER "  );
	return $conexion ;
}

function Desconectar($conexion){
	pg_close($conexion);
}

$conexion=Obtener_Conexion();
$sql=" select distinct p.num_prov, p.nom_prov from invprov p, swpr_vlineas l where p.num_prov=l.num_prov order by nom_prov ";
$res=pg_query($conexion,$sql)  or die ("Error $sql ");
$total=pg_num_rows($res);
//echo "<script>";
echo " collection = [ ";
while ($reg=pg_fetch_array($res)){
	echo chr(39).$reg[1].chr(39).",";
}
echo " ]; ";
//echo "</script>";
Desconectar($conexion);
	
?>